<?php

/**
 * This is the model class for table "kib_b".
 *
 * The followings are the available columns in table 'kib_b':
 * @property string $kode_kb
 * @property string $kode_png
 * @property string $kode_aset
 * @property string $no_reg
 * @property string $merek
 * @property integer $jml_cc
 * @property string $bhn_dasar
 * @property string $thn_buat
 * @property string $thn_beli
 * @property string $no_rangka
 * @property string $no_mesin
 * @property string $no_pol
 * @property string $no_bpkb
 * @property string $asal
 * @property double $harga_prh
 * @property double $harga_pas
 * @property string $ket_aset
 * @property string $kode_milik
 * @property string $kondisi
 */
class KibB extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'kib_b';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('jml_cc', 'numerical', 'integerOnly'=>true),
			array('harga_prh, harga_pas', 'numerical'),
			array('kode_png, thn_buat, thn_beli', 'length', 'max'=>4),
			array('kode_aset', 'length', 'max'=>14),
			array('no_reg, merek, bhn_dasar, asal, kondisi', 'length', 'max'=>25),
			array('no_rangka, no_mesin', 'length', 'max'=>45),
			array('no_pol', 'length', 'max'=>9),
			array('no_bpkb', 'length', 'max'=>20),
			array('kode_milik', 'length', 'max'=>2),
			array('ket_aset', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('kode_kb, kode_png, kode_aset, no_reg, merek, jml_cc, bhn_dasar, thn_buat, thn_beli, no_rangka, no_mesin, no_pol, no_bpkb, asal, harga_prh, harga_pas, ket_aset, kode_milik, kondisi', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'kode_kb' => 'Kode Kb',
			'kode_png' => 'Kode Png',
			'kode_aset' => 'Kode Aset',
			'no_reg' => 'No Reg',
			'merek' => 'Merek',
			'jml_cc' => 'Jml Cc',
			'bhn_dasar' => 'Bhn Dasar',
			'thn_buat' => 'Thn Buat',
			'thn_beli' => 'Thn Beli',
			'no_rangka' => 'No Rangka',
			'no_mesin' => 'No Mesin',
			'no_pol' => 'No Pol',
			'no_bpkb' => 'No Bpkb',
			'asal' => 'Asal',
			'harga_prh' => 'Harga Prh',
			'harga_pas' => 'Harga Pas',
			'ket_aset' => 'Ket Aset',
			'kode_milik' => 'Kode Milik',
			'kondisi' => 'Kondisi',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('kode_kb',$this->kode_kb,true);
		$criteria->compare('kode_png',$this->kode_png,true);
		$criteria->compare('kode_aset',$this->kode_aset,true);
		$criteria->compare('no_reg',$this->no_reg,true);
		$criteria->compare('merek',$this->merek,true);
		$criteria->compare('jml_cc',$this->jml_cc);
		$criteria->compare('bhn_dasar',$this->bhn_dasar,true);
		$criteria->compare('thn_buat',$this->thn_buat,true);
		$criteria->compare('thn_beli',$this->thn_beli,true);
		$criteria->compare('no_rangka',$this->no_rangka,true);
		$criteria->compare('no_mesin',$this->no_mesin,true);
		$criteria->compare('no_pol',$this->no_pol,true);
		$criteria->compare('no_bpkb',$this->no_bpkb,true);
		$criteria->compare('asal',$this->asal,true);
		$criteria->compare('harga_prh',$this->harga_prh);
		$criteria->compare('harga_pas',$this->harga_pas);
		$criteria->compare('ket_aset',$this->ket_aset,true);
		$criteria->compare('kode_milik',$this->kode_milik,true);
		$criteria->compare('kondisi',$this->kondisi,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return KibB the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
